<?php
/**
 * Date: 2017/4/20
 * Author:DuanHui
 */

namespace app\admin\validate;
use think\Db;
use tool\Common;
//验证规则

class Article extends Base{
    // 添加新闻
    public static function addNews(){

        return [
            'rule' => [
                'title' => 'require',
                'introduce' => 'require',
                'thumb' => 'require',
                'status' => 'require|number',
               'typeID' => 'require|number'
            ],
            'msg' => [
                'title.require' => '标题不能为空不能为空',
                'introduce.require' => '简介不能为空',
                'thumb.require' => '标题图片不能为空',
                'status.require' => '状态不能为空',
                'status.number' => '状态必须是数字',
                'typeID.require' => '类型ID不能为空',
                'typeID.number' => '类型ID必须是数字'
            ]
        ];
    }

    // 更新新闻
    public static function updateNews(){
        return [
            'rule' => [
                 'articleID' => 'require|number',
                'title' => 'require',
                'introduce' => 'require',
                'thumb' => 'require',
                'status' => 'require|number',
                'typeID' => 'require|number'
            ],
            'msg' => [
                'articleID.require' => '新闻ID不能为空不能为空',
                'articleID.number' => '新闻ID必须是数字',
                'title.require' => '标题不能为空不能为空',
                'introduce.require' => '简介不能为空',
                'thumb.require' => '标题图片不能为空',
                'status.require' => '状态不能为空',
                'status.number' => '状态必须是数字',
                'typeID.require' => '类型ID不能为空',
                'typeID.number' => '类型ID必须是数字'
            ]
        ];
    }

    //根据新闻ID得到新闻内容

    public static function getNewsContentByArticeID ()
    {
        return [
            'rule' => [
                'articleID'=>'require|number',

            ],
            'msg' => [
                'articleID.require'=>'新闻ID不能为空',
                'articleID.number' => '新闻ID必须为数字'
            ]
        ];
    }


    //根据类型ID得到新闻列表

    public static function  getNewsContentByTypeID(){
        return [
            'rule' => [
                'typeID'=>'require|number',
            ],
            'msg' => [
                'typeID.require'=>'类型ID不能为空',
                'typeID.number'=>'类型ID必须是数字'
            ]
        ];
    }
}